package com.second.config;

import com.second.consts.RabbitConst;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitConfig {

    //sms队列
    @Bean
    public Queue smsQueue() {
        return new Queue(RabbitConst.SIMPLE_QUEUE);
    }

    //秒杀三个队列
    @Bean
    public DirectExchange ordDirectExchange() {
        return new DirectExchange(RabbitConst.ORD_SEC_DIRECT_EX);
    }

    @Bean
    public Queue ordQueue() {
        return new Queue(RabbitConst.ORD_SEC_QUEUE);
    }

    @Bean
    public Binding ordBinding() {
        return BindingBuilder.bind(ordQueue()).to(ordDirectExchange()).with(RabbitConst.ORD_SEC_QUEUE_RK);
    }
}
